{include file="public/header"/}
<link rel="stylesheet" href="{__PUBLIC_PATH}/admin/pcf/pcf_help.css?v={$version}"/>
<script src="{__PUBLIC_PATH}/common/js/jquery.js?v={$version}"></script>
<script src="{__PUBLIC_PATH}/admin/pcf/global.js?v={$version}"></script>
</head>
<body>
<div style="margin:10px;padding:15px;background:#fff;" class="layui-form seller-alone-form">
<div class="web-system">
<div class="layui-form">
    <div class="layui-form-item">
    <label class="layui-form-label"><b>*</b>模型名称</label>
    <div class="layui-input-inline">
     <input type="text" name="ntitle" value="" lay-verify="required" class="layui-input">
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label"><b>*</b>模型标识</label>
    <div class="layui-input-inline">
      <input type="text" name="nid" value="" id="nid" lay-verify="required|check_nid" class="layui-input" onkeyup="this.value=this.value.replace(/[^a-z0-9]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^a-z0-9]/g,''));">
    </div>
    <div class="layui-form-inline2" style="width:80%;margin-left:95px;">
        与文档的模板相关连，建议由小写字母、数字组成，因为部份Unix系统无法识别中文文件。<br/>
        列表模板是：lists_模型标识.htm<br/>
        文档模板是：view_模型标识.htm
    </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">标题重复</label>
    <div class="layui-input-inline w70">
        <input type="checkbox" lay-filter="is_repeat_title" lay-skin="switch" lay-text="是|否" checked>
        <input type="hidden" name="is_repeat_title" value="1" />
    </div>
    <div class="layui-input-inline layui-btn-container" >
      <div class="layui-form-mid layui-word-aux ey_helptips"></div>
      <div class="layui-form-inline2 ey_helptips_txt">新增/编辑文档时，是否允许标题的重复</div>
    </div>
    </div>
    <div class="layui-form-item">
    <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
    </div>
    </div>
</div>
</div>
</div>
{include file="public/footer"/}
<script>
  layui.use(['layer', 'form'], function () {
     var $ = layui.$,
        layer = layui.layer,
        form = layui.form;
        layer = layui.layer;
        // 监听开关
        form.on('switch', function(data){
          var elemId = data.elem.attributes['lay-filter']['nodeValue'];
          if (data.elem.checked) {
            this.value = 1;
          } else {
            this.value = 0;
          }
          $("input[name='"+elemId+"']").val(this.value);
        });
        //监听提交
        form.on('submit(formSubmit)', function(data){
            layer.load(2);
            $.ajax({
                type : 'post',
                url : '{:url("/channel.type/add")}',
                data : data.field,
                dataType : 'json',
                success : function(res){
                    layer.closeAll('loading');
                    if(res.status){
                        layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                            parent.window.location.href = res.url;
                        });
                    }else{
                        layer.msg(res.msg, {icon: 2, time: 1000});
                    }
                },
                error: function(e){
                    layer.closeAll('loading');
                    layer.msg("未知错误，操作中断！", {icon: 2, time: 1000});
                }
            });
            return false;
        })
    });
</script>